From 292f358b4cc72a2aea7c344127e10a4e07b0b211 Mon Sep 17 00:00:00 2001 From: robertl Date: Fri, 10 Nov 2006 01:39:05 +0000 Subject: [PATCH] Use the Windows-proprietary MoveFileEx to rename files in KML writer for atomicity. --- gpsbabel/kml.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/gpsbabel/kml.c b/gpsbabel/kml.c index cd92713a0..8178a3f95 100644 --- a/gpsbabel/kml.c +++ b/gpsbabel/kml.c @@ -288,15 +288,8 @@ kml_wr_deinit(void) if (posnfilenametmp) { #if __WIN32__ - /* - * This is gross. - * Windows does not offer an atomic rename; we must - * explictly remove the destination here which exposes - * a window where a polled reader of this file could find - * the file to be missing. Windows readers will simply - * have to retry on this case. - */ - _unlink(posnfilename); + MoveFileEx(posnfilenametmp, posnfilename, + MOVEFILE_REPLACE_EXISTING); #endif rename(posnfilenametmp, posnfilename); xfree(posnfilenametmp); -- 2.30.2